package com.atguigu.juc.java8基础;

import java.util.concurrent.CompletableFuture;

public class CompletableFutureDemo {

    public static void main(String[] args) throws Exception{

        CompletableFuture<Void> completableFuture = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName() + "没有返回, update mysql ok");
        });
        completableFuture.get();

        CompletableFuture.supplyAsync(()->{
             System.out.println(Thread.currentThread().getName() + "有返回, insert mysql ok");
            return 1024;
        }).whenComplete((t,u)->{
            System.out.println("***t:" + t);
            System.out.println("***t:" + u);
        });
    }
}
